import React from "react";

import { connect } from "react-redux";

function Header(props) {
  return (
    <div>
      <h1>Header - {props.a}</h1>
      <button
        onClick={() => {
          props.add();
        }}
      >
        +
      </button>
    </div>
  );
}

const mapStateToProps = (state) => {
  return {
    a: state.count,
  };
};

const mapDispatchToProps = {
  // key: value
  //      value - 函数
  //   action creates
  add() {
    return { type: "increment" };
  },
};

export default connect(mapStateToProps, mapDispatchToProps)(Header);
